#include <iostream>
#include <algorithm>
#include <string>
#include <conio.h>

#include "temp.hpp"
#include "graph.hpp"

void my_print_tree(const tree<std::string>& tr, tree<std::string>::pre_order_iterator it, tree<std::string>::pre_order_iterator end)
{
	if(!tr.is_valid(it)) return;
	int rootdepth=tr.depth(it);
	std::cout << "-----" << std::endl;
	while(it!=end) {
		for(int i=0; i<tr.depth(it)-rootdepth; ++i) 
			std::cout << "  ";
		std::cout << (*it) << std::endl << std::flush;
		++it;
	}
	std::cout << "-----" << std::endl;
}


void main()
{
	std::cout << "Hello, World \n";

	tree<std::string> tr;
	tree<std::string>::iterator top, one, two, loc, banana;

	top=tr.begin();
	one=tr.insert(top, "one");
	two=tr.append_child(one, "two");
	tr.append_child(one, "two1");
	tr.append_child(two, "apple");
	banana=tr.append_child(two, "banana");
	tr.append_child(banana,"cherry");
	tr.append_child(two, "peach");
	tr.append_child(one,"three");

	my_print_tree(tr, tr.begin(), tr.end());

	graph<int> _graph;
	int _i = 1;

	graph<int>::nodeIterator _node = _graph.Insert(_i);

	_i = 2;
	graph<int>::nodeIterator _node2 = _graph.AppendChild(_node, _i);
	_i = 5;
	graph<int>::nodeIterator _node5 = _graph.AppendChild(_node2, _i);

	_i = 4;
	graph<int>::nodeIterator _node4 = _graph.AppendChild(_node, _i);
	_graph.AppendChild(_node4, _node5);
	_i = 6;
	graph<int>::nodeIterator _node6 = _graph.Insert(_i);
	_graph.AppendChild(_node4, _node6);

	_i = 3;
	graph<int>::nodeIterator _node3 = _graph.AppendChild(_node, _i);
	_graph.AppendChild(_node3, _node6);

	//_graph.FindPath(_node, _node6);

	graph<int>::DF_iterator _DF_it = _graph.begin(_node);
	graph<int>::DF_iterator _DF_it_end = _graph.end();
	for ( ; _DF_it != _DF_it_end; _DF_it++)
	{
		std::cout << (*_DF_it) << "\n";
	}

	_getch();
}